<!doctype html>
<html lang="en">
<head>
	<script >
		var path="${path}";
	</script>
    <meta charset="UTF-8">
    <title>淘惠帮</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="${resources}/plugins/fontAwesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/common.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/releaseLifeCircle.css" rel="stylesheet" type="text/css">
</head>
<body>
    <div id="container">
        <div class="formBox">
            <form action="">
                <p>
                    <input type="text" name="title" id="title" placeholder="标题 4-25个字" minlength="4" maxlength="25">
                </p>
                <p>
                    <textarea  name="content" id="content" rows="10" minlength="20" maxlength="700" placeholder="内容 10-700字"></textarea>
                </p>
                <p>
                    <button class="btn">发表</button>
                </p>
            </form>
        </div>
        <div id="uploadImg"></div>
    </div>
</body>
    <script src="${resources}/plugins/jquery/2.2.2/jquery.min.js"></script>
    <script src="${resources}/js/plupload.full.min.js"></script>
    <script src="${resources}/js/plupload.js"></script>
    <script src="${resources}/js/common.js"></script>
   
    <!--限制文本框输入字数-->
    <script src="${resources}/js/releaseLiftCicle.js"></script>
    <!-- 发表 -->
    <script>
	   var img=[];
		uploadImg.plupload({
		    container: "#uploadImg",
		    url: "${path}/upload/pic",
		    max: 3,
		    callback: function (data) {
		    	var image=[];
				console.log(data);
		    	for(var i in data){
		    		image.push(JSON.parse(data[i]));
		    	}
		    	img.push(image[0].result);
				console.log(img);
		    }
		});
    
    
    
    	$(".btn").on("click",function(){
    	
    	    var title = $("#title").val();
    		var content = $("#content").val();
			 $.ajax({
	     		type:"post",
	     		async:true, 
	        	url:"${path}/bbs/topic/create",
	        	data:{
	        		name:title,
	        		content:content,
	        		"board.id":'${boardid}',
	        		picList:img
	        	},
	     		success:function (data) {
	     			if(data.code==000){
	     				window.location.href="${path}/bbs";
	     			}
	     		}
	     	});
	     	//ajax end	
     	})		
    </script>
</html>